#pragma once

#include <vector>
#include <string>
#include <sstream>

#include "Local_connection.h"
#include "Vector2D.h"

class Logic_interface {
public:
	Logic_interface(void);
	~Logic_interface(void);

	bool connect_to_logic_module();

	int request_ai_move(std::string board, int player, int difficulty);
	int request_new_game();
	int request_board_width();
	int request_move_validation(std::string board, int player, Vector2D origin, Vector2D final);
	int request_winner_verification(std::string board, int player);
	int request_possible_moves(std::string board, int player, Vector2D position);

	int parse_ai_move(Vector2D &origin, Vector2D &final);
	int parse_new_game(std::string &board, int &player);
	int parse_board_width(int &board_width);
	int parse_move_validation(bool &valid);
	int parse_winner_verification(bool &won);
	int parse_possible_moves(std::vector<Vector2D> &moves);

	static int get_code_error_no_data_available();
	static int get_code_error_server_disconnect();
	static int get_code_invalid_request();
	static int get_code_success();
	Local_connection m_connection;
private:
	static int get_error(int error_code, std::string received_message = "");

	static const int K_ERROR_NO_DATA_AVAILABLE;
	static const int K_ERROR_SERVER_DISCONNECT;
	static const int K_INVALID_REQUEST;
	static const int K_SUCCESS;

	
};

